# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=rest-server
pkgver=0.12.1
pkgrel=4
pkgdesc="A high performance HTTP server that implements restic's REST backend API"
url="https://github.com/restic/rest-server"
arch="all"
license="BSD-2-Clause"
makedepends="go"
options="net chmod-clean"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver-2.tar.gz::https://github.com/restic/rest-server/archive/v$pkgver.tar.gz
	$pkgname.confd
	$pkgname.initd"
builddir="$srcdir/src/github.com/restic/$pkgname"

export GOPATH="$srcdir"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	mkdir -p "${builddir%/*}"
	ln -s "$srcdir"/$pkgname-$pkgver "$builddir"
	default_prepare
}

build() {
	go build -v ./cmd/...
}

check() {
	go test -v . ./cmd/rest-server
}

package() {
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm644 README.md \
		"$pkgdir"/usr/share/doc/$pkgname/README.md

	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
113a1b310845bafe92fc4ee60aadd0f0dc8c5f4f1676706c89c48e291937c616ee33b57febd7a41d99dc57adb250e7f34de1c302cf685a44f009585acaccde44  rest-server-0.12.1-2.tar.gz
cd9e4d3df04c26aa602a57196bdfb14d7ad6e957f1d9596a09e596b9d01543eee08474817ba47192659fe6f5ab15b8fa64400fb6a8d24111f5c792b1412f5e5b  rest-server.confd
185c0022d07c66fcee2d84af1bb0a11ac0753bd79deb8f5ae7dc2bd84909886aa3e58f42cd6ace4f191da6128d0385036948d4a8accd14cf9cdb9603001b9aca  rest-server.initd
"
